/**
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package projekt;

// Imports
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.IOException;
import javax.swing.JFrame;

/**
 * Main class of the game that displays graphics in JFrame. and allows the frame
 * to be controlled via keyboard button presses.
 */
public class Dungeon extends JFrame implements Runnable {

// Stored Variables
    private int difficulty = 1;
    private NewLevel nw1;
    private Hero hero1 = new Hero(100, 10, 10, 0, 0, " ");
    /**
     * GameOver Object.
     */
    private GameOver go1;
    /**
     * ReadWrite object.
     */
    private ReadWrite rw1;
    /**
     * High score Object.
     */
    private HighScore score1;
    /**
     * AI class used for monsters.
     */
    private Ai ai;
    /**
     * Image used for double buffering.
     */
    private Image dbImage;
    /**
     * Graphics component used for double buffering.
     */
    private Graphics dbg;
    /**
     * Boolean to check if keys have been released.
     */
    private boolean hasMoved = false;
    /**
     * The first level of the game.
     */
    private Level level1;
    /**
     * Combat object used for combat calculations.
     */
    private Combat combat;
    /**
     * Pickup class used for picking up objects.
     */
    private PickUp pickup;
    /**
     * Max width and height.
     */
    private final int maxWiHi = 800;
    /**
     * The font size.
     */
    private final float fontSize = (float) 15.0;
    /**
     * Player name variable.
     */
    private String player;
    /**
     * Array Length.
     */
    private final int arrayLength = 40;
    /**
     * X Position for the player status.
     */
    private final int statusX = 20;
    /**
     * Y position for player health.
     */
    private final int statusHealthY = 600;
    /**
     * Y position for player damage.
     */
    private final int statusDmgY = 620;
    /**
     * Y position for player armor.
     */
    private final int statusArmorY = 640;
    /**
     * Y position for player gold.
     */
    private final int statusGoldY = 660;
    /**
     * Y position for player XP.
     */
    private final int statusXpY = 680;
    /**
     * X position for the event log marker.
     */
    private final int eventLogX = 350;
    /**
     * GUI class for text.
     */
    private Gui gui1 = new Gui(this);
    private Dungeon.KeyboardListener key1;

    /**
     * Constructor for the dungeon. Sets up the JFrame and the first level.
     */
    public Dungeon() {
        key1 = new Dungeon.KeyboardListener();
        go1 = new GameOver(this);
        this.level1 = new Level(1);
        this.combat = new Combat(this);
        this.pickup = new PickUp(this);
        this.ai = new Ai(this);
        this.rw1 = new ReadWrite();
        this.score1 = new HighScore();
        try {
            this.score1 = (HighScore) rw1.readObject();
        } catch (ClassNotFoundException e) {
            this.score1 = new HighScore();
        } catch (IOException e) {
            this.score1 = new HighScore();
        }
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

        int x = (dim.width - maxWiHi) / 2;
        int y = (dim.height - maxWiHi) / 2;
        setLocation(x, y);

        setTitle("Diablo 0.5");
        setSize(maxWiHi, maxWiHi);
        setResizable(false);
        setVisible(false);
        addKeyListener(key1);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBackground(Color.black);
    }

    public ReadWrite getRw1() {
        return rw1;
    }

//Run Thread.
    @Override
    public final void run() {
        try { //Run thread loop
            while (true) {
            }
        } //Catch Errors
        catch (Exception e) {
            System.out.println("Error");
        }

    }

    /**
     * Main function creates the dungeon and runs it in a thread.
     *
     * @param args = arguments.
     */
    public static void main(final String[] args) {
        Dungeon dg = new Dungeon();
        new Start(dg);
        Thread t1 = new Thread(dg);
        t1.start();
    }

    /**
     * Accepts the player name from the start screen and turns the frame on.
     *
     * @param h hero name.
     */
    public final void trueStart(final String h) {
        player = h;
        hero1.setName(player);
        levelBuilder(level1, 1);
        this.setVisible(true);
    }

    /**
     * Gets the first level.
     *
     * @return = returns the first level.
     */
    public final Level getLevel1() {
        return level1;
    }

    /*
     * Paint class receives the painted image and displays it to the jframe.
     */
    @Override
    public final void paint(final Graphics g) {
        dbImage = createImage(getWidth(), getHeight());
        dbg = dbImage.getGraphics();
        paintComponent(dbg);
        g.drawImage(dbImage, 0, 0, this);
    }

    /**
     * Double buffering component that draws the image before display.
     *
     * @param g = graphics component.
     */
    public final void paintComponent(final Graphics g) {
        g.setColor(Color.WHITE);
        g.setFont(g.getFont().deriveFont(fontSize));
        for (int x = 0; x < arrayLength; x = x + 1) {
            for (int y = 0; y < arrayLength; y = y + 1) {
                g.drawString(level1.getGrid(x, y).getSymbol(),
                        level1.getGrid(x, y).getX(),
                        level1.getGrid(x, y).getY());
            }
        }
        g.drawString(gui1.getHealth(), statusX, statusHealthY);
        g.drawString(gui1.getArmor(), statusX, statusArmorY);
        g.drawString(gui1.getDmg(), statusX, statusDmgY);
        g.drawString(gui1.getGold(), statusX, statusGoldY);
        g.drawString(gui1.getXp(), statusX, statusXpY);
        g.drawString("Event Log:", eventLogX, statusHealthY);
        g.drawString(gui1.getEvent(0), eventLogX, statusArmorY);
        g.drawString(gui1.getEvent(1), eventLogX, statusDmgY);
        g.drawString(gui1.getEvent(2), eventLogX, statusGoldY);
        g.drawString(gui1.getEvent(3), eventLogX, statusXpY);
        repaint();
    }

    /**
     * Returns the gui class.
     *
     * @return Gui1.
     */
    public final Gui getGui() {
        return gui1;
    }

    /**
     * Returns the Combat class.
     *
     * @return combat.
     */
    public final Combat getCombat() {
        return combat;
    }

    public final void nextLevel(Hero h) {
        difficulty++;
        this.setVisible(false);
        hero1 = h;
        if (level1.getCurrUsage() == 1) {
            levelBuilder(level1, 2);
        } else {
            levelBuilder(level1, 1);
        }
        nw1 = new NewLevel(this);
        key1.setDisable(true);

    }

    public final void startLevel() {
        setVisible(true);
        key1.setDisable(false);
        nw1.dispose();
    }

    /**
     * Builds a level that is supplied based on which stage is chosen.
     *
     * @param l = level supplied.
     * @param stage = which stage to build.
     */
    public final void levelBuilder(final Level l, final int stage) {
        for (int x1 = 0; x1 < 40; x1++) {
            for (int y1 = 0; y1 < 40; y1++) {
                l.addLevelObject(x1, y1, new Background());
            }
        }
        switch (stage) {
            case 1:


//Room 1
                l.addLevelObject(3, 1, new Wall());
                l.addLevelObject(3, 2, new Wall());
                l.addLevelObject(3, 3, new Wall());
                l.addLevelObject(3, 4, new Wall());
                l.addLevelObject(3, 5, new Wall());
                l.addLevelObject(4, 1, new Wall());
                l.addLevelObject(4, 5, new Wall());
                l.addLevelObject(5, 1, new Wall());
                l.addLevelObject(6, 1, new Wall());
                l.addLevelObject(6, 5, new Wall());
                l.addLevelObject(7, 1, new Wall());
                l.addLevelObject(7, 5, new Wall());
                l.addLevelObject(8, 1, new Wall());
                l.addLevelObject(8, 2, new Wall());
                l.addLevelObject(8, 3, new Wall());
                l.addLevelObject(8, 4, new Wall());
                l.addLevelObject(8, 5, new Wall());
//Room 2
                l.addLevelObject(2, 11, new Wall());
                l.addLevelObject(2, 12, new Wall());
                l.addLevelObject(2, 13, new Wall());
                l.addLevelObject(2, 14, new Wall());
                l.addLevelObject(2, 15, new Wall());
                l.addLevelObject(3, 15, new Wall());
                l.addLevelObject(4, 11, new Wall());
                l.addLevelObject(4, 15, new Wall());
                l.addLevelObject(5, 11, new Wall());
                l.addLevelObject(5, 15, new Wall());
                l.addLevelObject(6, 11, new Wall());
                l.addLevelObject(6, 15, new Wall());
                l.addLevelObject(7, 11, new Wall());
                l.addLevelObject(7, 12, new Wall());
                l.addLevelObject(7, 13, new Wall());
                l.addLevelObject(7, 15, new Wall());
//Room 3
                l.addLevelObject(13, 3, new Wall());
                l.addLevelObject(13, 4, new Wall());
                l.addLevelObject(13, 5, new Wall());
                l.addLevelObject(13, 5, new Wall());
                l.addLevelObject(13, 6, new Wall());
                l.addLevelObject(13, 8, new Wall());
                l.addLevelObject(13, 9, new Wall());
                l.addLevelObject(13, 10, new Wall());
                l.addLevelObject(13, 11, new Wall());
                l.addLevelObject(13, 12, new Wall());
                l.addLevelObject(14, 3, new Wall());
                l.addLevelObject(14, 12, new Wall());
                l.addLevelObject(15, 3, new Wall());
                l.addLevelObject(15, 12, new Wall());
                l.addLevelObject(16, 3, new Wall());
                l.addLevelObject(16, 12, new Wall());
                l.addLevelObject(17, 3, new Wall());
                l.addLevelObject(17, 12, new Wall());
                l.addLevelObject(18, 3, new Wall());
                l.addLevelObject(18, 12, new Wall());
                l.addLevelObject(19, 3, new Wall());
                l.addLevelObject(19, 4, new Wall());
                l.addLevelObject(19, 5, new Wall());
                l.addLevelObject(19, 6, new Wall());
                l.addLevelObject(19, 7, new Wall());
                l.addLevelObject(19, 8, new Wall());
                l.addLevelObject(19, 9, new Wall());
                l.addLevelObject(19, 11, new Wall());
                l.addLevelObject(19, 12, new Wall());
//Room 4
                l.addLevelObject(23, 1, new Wall());
                l.addLevelObject(23, 2, new Wall());
                l.addLevelObject(23, 3, new Wall());
                l.addLevelObject(23, 4, new Wall());
                l.addLevelObject(23, 5, new Wall());
                l.addLevelObject(24, 1, new Wall());
                l.addLevelObject(24, 5, new Wall());
                l.addLevelObject(25, 1, new Wall());
                l.addLevelObject(26, 1, new Wall());
                l.addLevelObject(26, 5, new Wall());
                l.addLevelObject(27, 1, new Wall());
                l.addLevelObject(27, 2, new Wall());
                l.addLevelObject(27, 3, new Wall());
                l.addLevelObject(27, 4, new Wall());
                l.addLevelObject(27, 5, new Wall());
//Room 5
                l.addLevelObject(20, 16, new Wall());
                l.addLevelObject(20, 17, new Wall());
                l.addLevelObject(20, 18, new Wall());
                l.addLevelObject(20, 19, new Wall());
                l.addLevelObject(20, 20, new Wall());
                l.addLevelObject(20, 21, new Wall());
                l.addLevelObject(20, 22, new Wall());
                l.addLevelObject(20, 23, new Wall());
                l.addLevelObject(20, 24, new Wall());
                l.addLevelObject(20, 25, new Wall());
                l.addLevelObject(20, 26, new Wall());
                l.addLevelObject(21, 26, new Wall());
                l.addLevelObject(22, 16, new Wall());
                l.addLevelObject(22, 26, new Wall());
                l.addLevelObject(23, 16, new Wall());
                l.addLevelObject(23, 26, new Wall());
                l.addLevelObject(24, 16, new Wall());
                l.addLevelObject(24, 26, new Wall());
                l.addLevelObject(25, 16, new Wall());
                l.addLevelObject(25, 26, new Wall());
                l.addLevelObject(26, 16, new Wall());
                l.addLevelObject(27, 16, new Wall());
                l.addLevelObject(27, 17, new Wall());
                l.addLevelObject(27, 18, new Wall());
                l.addLevelObject(27, 19, new Wall());
                l.addLevelObject(27, 20, new Wall());
                l.addLevelObject(27, 21, new Wall());
                l.addLevelObject(27, 22, new Wall());
                l.addLevelObject(27, 23, new Wall());
                l.addLevelObject(27, 24, new Wall());
                l.addLevelObject(27, 25, new Wall());
                l.addLevelObject(27, 26, new Wall());
//Room 6
                l.addLevelObject(17, 32, new Wall());
                l.addLevelObject(17, 33, new Wall());
                l.addLevelObject(17, 34, new Wall());
                l.addLevelObject(17, 35, new Wall());
                l.addLevelObject(17, 37, new Wall());
                l.addLevelObject(17, 38, new Wall());
                l.addLevelObject(18, 32, new Wall());
                l.addLevelObject(18, 38, new Wall());
                l.addLevelObject(19, 32, new Wall());
                l.addLevelObject(19, 38, new Wall());
                l.addLevelObject(20, 32, new Wall());
                l.addLevelObject(20, 38, new Wall());
                l.addLevelObject(21, 32, new Wall());
                l.addLevelObject(21, 38, new Wall());
                l.addLevelObject(22, 32, new Wall());
                l.addLevelObject(22, 38, new Wall());
                l.addLevelObject(23, 32, new Wall());
                l.addLevelObject(23, 38, new Wall());
                l.addLevelObject(24, 38, new Wall());
                l.addLevelObject(25, 32, new Wall());
                l.addLevelObject(25, 38, new Wall());
                l.addLevelObject(26, 32, new Wall());
                l.addLevelObject(26, 38, new Wall());
                l.addLevelObject(27, 32, new Wall());
                l.addLevelObject(27, 33, new Wall());
                l.addLevelObject(27, 34, new Wall());
                l.addLevelObject(27, 35, new Wall());
                l.addLevelObject(27, 36, new Wall());
                l.addLevelObject(27, 37, new Wall());
                l.addLevelObject(27, 38, new Wall());
//Room 7
                l.addLevelObject(1, 26, new Wall());
                l.addLevelObject(1, 27, new Wall());
                l.addLevelObject(1, 28, new Wall());
                l.addLevelObject(1, 29, new Wall());
                l.addLevelObject(1, 30, new Wall());
                l.addLevelObject(1, 31, new Wall());
                l.addLevelObject(1, 32, new Wall());
                l.addLevelObject(1, 33, new Wall());
                l.addLevelObject(1, 34, new Wall());
                l.addLevelObject(1, 35, new Wall());
                l.addLevelObject(1, 36, new Wall());
                l.addLevelObject(1, 37, new Wall());
                l.addLevelObject(1, 38, new Wall());
                l.addLevelObject(2, 26, new Wall());
                l.addLevelObject(2, 38, new Wall());
                l.addLevelObject(3, 38, new Wall());
                l.addLevelObject(4, 26, new Wall());
                l.addLevelObject(4, 36, new Wall());
                l.addLevelObject(4, 37, new Wall());
                l.addLevelObject(4, 38, new Wall());
                l.addLevelObject(5, 26, new Wall());
                l.addLevelObject(5, 36, new Wall());
                l.addLevelObject(6, 26, new Wall());
                l.addLevelObject(6, 27, new Wall());
                l.addLevelObject(6, 28, new Wall());
                l.addLevelObject(6, 29, new Wall());
                l.addLevelObject(6, 30, new Wall());
                l.addLevelObject(6, 31, new Wall());
                l.addLevelObject(6, 32, new Wall());
                l.addLevelObject(6, 33, new Wall());
                l.addLevelObject(6, 34, new Wall());
                l.addLevelObject(6, 36, new Wall());
//Room 8
                l.addLevelObject(9, 16, new Wall());
                l.addLevelObject(9, 17, new Wall());
                l.addLevelObject(9, 18, new Wall());
                l.addLevelObject(9, 19, new Wall());
                l.addLevelObject(9, 21, new Wall());
                l.addLevelObject(9, 22, new Wall());
                l.addLevelObject(9, 23, new Wall());
                l.addLevelObject(9, 24, new Wall());
                l.addLevelObject(9, 25, new Wall());
                l.addLevelObject(9, 26, new Wall());
                l.addLevelObject(9, 27, new Wall());
                l.addLevelObject(9, 28, new Wall());
                l.addLevelObject(9, 29, new Wall());
                l.addLevelObject(9, 30, new Wall());
                l.addLevelObject(10, 16, new Wall());
                l.addLevelObject(10, 30, new Wall());
                l.addLevelObject(11, 16, new Wall());
                l.addLevelObject(11, 30, new Wall());
                l.addLevelObject(12, 16, new Wall());
                l.addLevelObject(12, 30, new Wall());
                l.addLevelObject(13, 16, new Wall());
                l.addLevelObject(13, 30, new Wall());
                l.addLevelObject(14, 16, new Wall());
                l.addLevelObject(14, 30, new Wall());
                l.addLevelObject(15, 16, new Wall());
                l.addLevelObject(15, 30, new Wall());
                l.addLevelObject(16, 16, new Wall());
                l.addLevelObject(16, 30, new Wall());
                l.addLevelObject(17, 16, new Wall());
                l.addLevelObject(17, 17, new Wall());
                l.addLevelObject(17, 18, new Wall());
                l.addLevelObject(17, 19, new Wall());
                l.addLevelObject(17, 20, new Wall());
                l.addLevelObject(17, 21, new Wall());
                l.addLevelObject(17, 22, new Wall());
                l.addLevelObject(17, 23, new Wall());
                l.addLevelObject(17, 24, new Wall());
                l.addLevelObject(17, 25, new Wall());
                l.addLevelObject(17, 26, new Wall());
                l.addLevelObject(17, 27, new Wall());
                l.addLevelObject(17, 28, new Wall());
                l.addLevelObject(17, 29, new Wall());
                l.addLevelObject(17, 30, new Wall());

//Floor R1
//l.addLevelObject(4, 2, new Floor());
                l.addLevelObject(4, 3, new Floor());
                l.addLevelObject(4, 4, new Floor());
                l.addLevelObject(5, 2, new Floor());
                l.addLevelObject(5, 3, new Floor());
                l.addLevelObject(5, 4, new Floor());
                l.addLevelObject(5, 5, new Floor());
                l.addLevelObject(6, 2, new Floor());
                l.addLevelObject(6, 3, new Floor());
                l.addLevelObject(6, 4, new Floor());
                l.addLevelObject(7, 2, new Floor());
                l.addLevelObject(7, 3, new Floor());
                l.addLevelObject(7, 4, new Floor());
//Floor R1-2
                l.addLevelObject(5, 6, new Floor());
                l.addLevelObject(5, 7, new Floor());
                l.addLevelObject(5, 8, new Floor());
                l.addLevelObject(5, 9, new Floor());
                l.addLevelObject(4, 9, new Floor());
                l.addLevelObject(3, 9, new Floor());
                l.addLevelObject(3, 10, new Floor());
//Floor R2
                l.addLevelObject(3, 11, new Floor());
                l.addLevelObject(3, 12, new Floor());
                l.addLevelObject(3, 13, new Floor());
                l.addLevelObject(3, 14, new Floor());
                l.addLevelObject(4, 12, new Floor());
                l.addLevelObject(4, 13, new Floor());
                l.addLevelObject(4, 14, new Floor());
                l.addLevelObject(5, 13, new Floor());
                l.addLevelObject(5, 12, new Floor());
                l.addLevelObject(5, 14, new Floor());
                l.addLevelObject(6, 12, new Floor());
                l.addLevelObject(6, 13, new Floor());
                l.addLevelObject(6, 14, new Floor());
                l.addLevelObject(7, 14, new Floor());
//Floor R2-3
                l.addLevelObject(8, 14, new Floor());
                l.addLevelObject(9, 14, new Floor());
                l.addLevelObject(10, 7, new Floor());
                l.addLevelObject(10, 8, new Floor());
                l.addLevelObject(10, 9, new Floor());
                l.addLevelObject(10, 10, new Floor());
                l.addLevelObject(10, 14, new Floor());
                l.addLevelObject(11, 7, new Floor());
                l.addLevelObject(11, 10, new Floor());
                l.addLevelObject(11, 11, new Floor());
                l.addLevelObject(11, 12, new Floor());
                l.addLevelObject(11, 13, new Floor());
                l.addLevelObject(11, 14, new Floor());
                l.addLevelObject(12, 7, new Floor());
//Floor R3
                l.addLevelObject(13, 7, new Floor());
                l.addLevelObject(14, 4, new Floor());
                l.addLevelObject(14, 5, new Floor());
                l.addLevelObject(14, 6, new Floor());
                l.addLevelObject(14, 7, new Floor());
                l.addLevelObject(14, 8, new Floor());
                l.addLevelObject(14, 9, new Floor());
                l.addLevelObject(14, 10, new Floor());
                l.addLevelObject(14, 11, new Floor());
                l.addLevelObject(15, 4, new Floor());
                l.addLevelObject(15, 5, new Floor());
                l.addLevelObject(15, 6, new Floor());
                l.addLevelObject(15, 7, new Floor());
                l.addLevelObject(15, 8, new Floor());
                l.addLevelObject(15, 9, new Floor());
                l.addLevelObject(15, 10, new Floor());
                l.addLevelObject(15, 11, new Floor());
                l.addLevelObject(16, 4, new Floor());
                l.addLevelObject(16, 5, new Floor());
                l.addLevelObject(16, 6, new Floor());
                l.addLevelObject(16, 7, new Floor());
                l.addLevelObject(16, 8, new Floor());
                l.addLevelObject(16, 9, new Floor());
                l.addLevelObject(16, 10, new Floor());
                l.addLevelObject(16, 11, new Floor());
                l.addLevelObject(17, 4, new Floor());
                l.addLevelObject(17, 5, new Floor());
                l.addLevelObject(17, 6, new Floor());
                l.addLevelObject(17, 7, new Floor());
                l.addLevelObject(17, 8, new Floor());
                l.addLevelObject(17, 9, new Floor());
                l.addLevelObject(17, 10, new Floor());
                l.addLevelObject(17, 11, new Floor());
                l.addLevelObject(18, 4, new Floor());
                l.addLevelObject(18, 5, new Floor());
                l.addLevelObject(18, 6, new Floor());
                l.addLevelObject(18, 7, new Floor());
                l.addLevelObject(18, 8, new Floor());
                l.addLevelObject(18, 9, new Floor());
                l.addLevelObject(18, 10, new Floor());
                l.addLevelObject(18, 11, new Floor());
                l.addLevelObject(19, 10, new Floor());
//Floor 3-4-5
                l.addLevelObject(20, 10, new Floor());
                l.addLevelObject(21, 10, new Floor());
                l.addLevelObject(21, 14, new Floor());
                l.addLevelObject(21, 15, new Floor());
                l.addLevelObject(22, 7, new Floor());
                l.addLevelObject(22, 8, new Floor());
                l.addLevelObject(22, 9, new Floor());
                l.addLevelObject(22, 10, new Floor());
                l.addLevelObject(22, 11, new Floor());
                l.addLevelObject(22, 12, new Floor());
                l.addLevelObject(22, 13, new Floor());
                l.addLevelObject(22, 14, new Floor());
                l.addLevelObject(23, 7, new Floor());
                l.addLevelObject(24, 7, new Floor());
                l.addLevelObject(25, 6, new Floor());
                l.addLevelObject(25, 7, new Floor());
//Floor R4
                l.addLevelObject(24, 2, new Floor());
                l.addLevelObject(24, 3, new Floor());
                l.addLevelObject(24, 4, new Floor());
                l.addLevelObject(25, 2, new Floor());
                l.addLevelObject(25, 3, new Floor());
                l.addLevelObject(25, 4, new Floor());
                l.addLevelObject(25, 5, new Floor());
                l.addLevelObject(26, 2, new Floor());
                l.addLevelObject(26, 3, new Floor());
                l.addLevelObject(26, 4, new Floor());
//Floor R5
                l.addLevelObject(21, 16, new Floor());
                l.addLevelObject(21, 17, new Floor());
                l.addLevelObject(21, 18, new Floor());
                l.addLevelObject(21, 19, new Floor());
                l.addLevelObject(21, 20, new Floor());
                l.addLevelObject(21, 21, new Floor());
                l.addLevelObject(21, 22, new Floor());
                l.addLevelObject(21, 23, new Floor());
                l.addLevelObject(21, 24, new Floor());
                l.addLevelObject(21, 25, new Floor());
                l.addLevelObject(22, 17, new Floor());
                l.addLevelObject(22, 18, new Floor());
                l.addLevelObject(22, 19, new Floor());
                l.addLevelObject(22, 20, new Floor());
                l.addLevelObject(22, 21, new Floor());
                l.addLevelObject(22, 22, new Floor());
                l.addLevelObject(22, 23, new Floor());
                l.addLevelObject(22, 24, new Floor());
                l.addLevelObject(22, 25, new Floor());
                l.addLevelObject(23, 17, new Floor());
                l.addLevelObject(23, 18, new Floor());
                l.addLevelObject(23, 19, new Floor());
                l.addLevelObject(23, 20, new Floor());
                l.addLevelObject(23, 21, new Floor());
                l.addLevelObject(23, 22, new Floor());
                l.addLevelObject(23, 23, new Floor());
                l.addLevelObject(23, 24, new Floor());
                l.addLevelObject(23, 25, new Floor());
                l.addLevelObject(24, 17, new Floor());
                l.addLevelObject(24, 18, new Floor());
                l.addLevelObject(24, 19, new Floor());
                l.addLevelObject(24, 20, new Floor());
                l.addLevelObject(24, 21, new Floor());
                l.addLevelObject(24, 22, new Floor());
                l.addLevelObject(24, 23, new Floor());
                l.addLevelObject(24, 24, new Floor());
                l.addLevelObject(24, 25, new Floor());
                l.addLevelObject(25, 17, new Floor());
                l.addLevelObject(25, 18, new Floor());
                l.addLevelObject(25, 19, new Floor());
                l.addLevelObject(25, 20, new Floor());
                l.addLevelObject(25, 21, new Floor());
                l.addLevelObject(25, 22, new Floor());
                l.addLevelObject(25, 23, new Floor());
                l.addLevelObject(25, 24, new Floor());
                l.addLevelObject(25, 25, new Floor());
                l.addLevelObject(26, 17, new Floor());
                l.addLevelObject(26, 18, new Floor());
                l.addLevelObject(26, 19, new Floor());
                l.addLevelObject(26, 20, new Floor());
                l.addLevelObject(26, 21, new Floor());
                l.addLevelObject(26, 22, new Floor());
                l.addLevelObject(26, 23, new Floor());
                l.addLevelObject(26, 24, new Floor());
                l.addLevelObject(26, 25, new Floor());
                l.addLevelObject(26, 26, new Floor());
//Floor R5-6
                l.addLevelObject(24, 28, new Floor());
                l.addLevelObject(24, 29, new Floor());
                l.addLevelObject(24, 30, new Floor());
                l.addLevelObject(24, 31, new Floor());
                l.addLevelObject(25, 28, new Floor());
                l.addLevelObject(26, 27, new Floor());
                l.addLevelObject(26, 28, new Floor());
//Floor R6
                l.addLevelObject(17, 36, new Floor());
                l.addLevelObject(18, 33, new Floor());
                l.addLevelObject(18, 34, new Floor());
                l.addLevelObject(18, 35, new Floor());
                l.addLevelObject(18, 36, new Floor());
                l.addLevelObject(18, 37, new Floor());
                l.addLevelObject(19, 33, new Floor());
                l.addLevelObject(19, 34, new Floor());
                l.addLevelObject(19, 35, new Floor());
                l.addLevelObject(19, 36, new Floor());
                l.addLevelObject(19, 37, new Floor());
                l.addLevelObject(20, 33, new Floor());
                l.addLevelObject(20, 34, new Floor());
                l.addLevelObject(20, 35, new Floor());
                l.addLevelObject(20, 36, new Floor());
                l.addLevelObject(20, 37, new Floor());
                l.addLevelObject(21, 33, new Floor());
                l.addLevelObject(21, 34, new Floor());
                l.addLevelObject(21, 35, new Floor());
                l.addLevelObject(21, 36, new Floor());
                l.addLevelObject(21, 37, new Floor());
                l.addLevelObject(22, 33, new Floor());
                l.addLevelObject(22, 34, new Floor());
                l.addLevelObject(22, 35, new Floor());
                l.addLevelObject(22, 36, new Floor());
                l.addLevelObject(22, 37, new Floor());
                l.addLevelObject(23, 33, new Floor());
                l.addLevelObject(23, 34, new Floor());
                l.addLevelObject(23, 35, new Floor());
                l.addLevelObject(23, 36, new Floor());
                l.addLevelObject(23, 37, new Floor());
                l.addLevelObject(24, 32, new Floor());
                l.addLevelObject(24, 33, new Floor());
                l.addLevelObject(24, 34, new Floor());
                l.addLevelObject(24, 35, new Floor());
                l.addLevelObject(24, 36, new Floor());
                l.addLevelObject(24, 37, new Floor());
                l.addLevelObject(25, 33, new Floor());
                l.addLevelObject(25, 34, new Floor());
                l.addLevelObject(25, 35, new Floor());
                l.addLevelObject(25, 36, new Floor());
                l.addLevelObject(25, 37, new Floor());
                l.addLevelObject(26, 33, new Floor());
                l.addLevelObject(26, 34, new Floor());
                l.addLevelObject(26, 35, new Floor());
                l.addLevelObject(26, 36, new Floor());
                l.addLevelObject(26, 37, new Floor());
//Floor R6-7
                l.addLevelObject(7, 35, new Floor());
                l.addLevelObject(7, 36, new Floor());
                l.addLevelObject(7, 37, new Floor());
                l.addLevelObject(7, 38, new Floor());
                l.addLevelObject(8, 38, new Floor());
                l.addLevelObject(9, 38, new Floor());
                l.addLevelObject(10, 38, new Floor());
                l.addLevelObject(11, 38, new Floor());
                l.addLevelObject(12, 36, new Floor());
                l.addLevelObject(12, 37, new Floor());
                l.addLevelObject(12, 38, new Floor());
                l.addLevelObject(13, 36, new Floor());
                l.addLevelObject(14, 36, new Floor());
                l.addLevelObject(15, 36, new Floor());
                l.addLevelObject(16, 36, new Floor());
//Floor R7
                l.addLevelObject(2, 27, new Floor());
                l.addLevelObject(2, 28, new Floor());
                l.addLevelObject(2, 29, new Floor());
                l.addLevelObject(2, 30, new Floor());
                l.addLevelObject(2, 31, new Floor());
                l.addLevelObject(2, 32, new Floor());
                l.addLevelObject(2, 33, new Floor());
                l.addLevelObject(2, 34, new Floor());
                l.addLevelObject(2, 35, new Floor());
                l.addLevelObject(2, 36, new Floor());
                l.addLevelObject(2, 37, new Floor());
                l.addLevelObject(3, 26, new Floor());
                l.addLevelObject(3, 27, new Floor());
                l.addLevelObject(3, 28, new Floor());
                l.addLevelObject(3, 29, new Floor());
                l.addLevelObject(3, 30, new Floor());
                l.addLevelObject(3, 31, new Floor());
                l.addLevelObject(3, 32, new Floor());
                l.addLevelObject(3, 33, new Floor());
                l.addLevelObject(3, 34, new Floor());
                l.addLevelObject(3, 35, new Floor());
                l.addLevelObject(3, 36, new Floor());
                l.addLevelObject(3, 37, new Floor());
                l.addLevelObject(4, 27, new Floor());
                l.addLevelObject(4, 28, new Floor());
                l.addLevelObject(4, 29, new Floor());
                l.addLevelObject(4, 30, new Floor());
                l.addLevelObject(4, 31, new Floor());
                l.addLevelObject(4, 32, new Floor());
                l.addLevelObject(4, 33, new Floor());
                l.addLevelObject(4, 34, new Floor());
                l.addLevelObject(4, 35, new Floor());
                l.addLevelObject(5, 27, new Floor());
                l.addLevelObject(5, 28, new Floor());
                l.addLevelObject(5, 29, new Floor());
                l.addLevelObject(5, 30, new Floor());
                l.addLevelObject(5, 31, new Floor());
                l.addLevelObject(5, 32, new Floor());
                l.addLevelObject(5, 33, new Floor());
                l.addLevelObject(5, 34, new Floor());
                l.addLevelObject(5, 35, new Floor());
                l.addLevelObject(6, 35, new Floor());
//Floor R7-8
                l.addLevelObject(3, 21, new Floor());
                l.addLevelObject(3, 22, new Floor());
                l.addLevelObject(3, 23, new Floor());
                l.addLevelObject(3, 24, new Floor());
                l.addLevelObject(3, 25, new Floor());
                l.addLevelObject(4, 21, new Floor());
                l.addLevelObject(5, 21, new Floor());
                l.addLevelObject(6, 21, new Floor());
                l.addLevelObject(7, 20, new Floor());
                l.addLevelObject(7, 21, new Floor());
                l.addLevelObject(8, 20, new Floor());
//Floor R8
                l.addLevelObject(9, 20, new Floor());
                for (int i = 17; i < 30; i++) {
                    for (int j = 10; j < 17; j++) {
                        l.addLevelObject(j, i, new Floor());
                    }
                }

//Monster & Items
//Room1
                l.addLevelObject(4, 2, hero1);
                l.addLevelObject(7, 3, new Weapon(10, "W", "Dagger"));

//Room2
                l.addLevelObject(5, 14, new Skeleton(40, 20, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(6, 12, new Gold(50, "$", "Gold pieces"));

//Room3
                l.addLevelObject(14, 11, new Potions(70, "♥", "Potion"));
                l.addLevelObject(15, 4, new Skeleton(40, 30, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(17, 11, new Skeleton(40, 30, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(18, 5, new Ghost(35, 20, 15, 25, 75, "Ghost", difficulty));

//Room4
                l.addLevelObject(24, 2, new Gold(55, "$", "Gold pieces"));
                l.addLevelObject(24, 3, new Potions(100, "♥", "Poition"));
                l.addLevelObject(25, 2, new Armor("Boots", "A", 13));
                l.addLevelObject(26, 2, new Gold(50, "$", "Gold pieces"));
                l.addLevelObject(26, 3, new Ring(10, 10, 10, "Ô", "Silver ring"));

//Room5
                l.addLevelObject(21, 19, new Ghost(35, 30, 15, 25, 75, "Ghost", difficulty));
                l.addLevelObject(21, 25, new Potions(100, "♥", "Potion"));
                l.addLevelObject(23, 23, new Skeleton(40, 20, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(24, 23, new Skeleton(40, 20, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(26, 18, new Ghost(35, 30, 5, 25, 75, "Ghost", difficulty));
                l.addLevelObject(26, 20, new Ghost(35, 30, 5, 25, 75, "Ghost", difficulty));

//Room6
                l.addLevelObject(26, 35, new Weapon(35, "W", "Giant Sword"));
                l.addLevelObject(26, 36, new Armor("Chest plate", "A", 34));
                l.addLevelObject(19, 35, new Dragon(80, 20, 24, 40, 125, "Dragon", difficulty));
                for (int i = 33; i < 38; i++) {
                    l.addLevelObject(18, i, new Gold(60, "$", "Gold pieces"));
                }

//Room7
                l.addLevelObject(2, 27, new Dragon(80, 20, 35, 35, 110, "Dragon", difficulty));
                l.addLevelObject(3, 35, new Skeleton(40, 20, 10, 10, 50, "Skeleton", difficulty));
                l.addLevelObject(3, 37, new Potions(250, "♥", "Great Potion"));
                l.addLevelObject(4, 27, new Dragon(80, 20, 35, 35, 110, "Dragon", difficulty));
                l.addLevelObject(5, 32, new Skeleton(40, 35, 10, 10, 50, "Skeleton", difficulty));

//Room8
                l.addLevelObject(15, 23, new Boss(100, 20, 25, 300, 500, "Boss", difficulty));
                l.setCurrUsage(1);
                break;

            case 2:
                //Room 1
                l.addLevelObject(9, 16, new Wall());
                l.addLevelObject(9, 17, new Wall());
                l.addLevelObject(9, 18, new Wall());
                l.addLevelObject(9, 19, new Wall());
                l.addLevelObject(9, 21, new Wall());
                l.addLevelObject(9, 22, new Wall());
                l.addLevelObject(9, 23, new Wall());
                l.addLevelObject(9, 24, new Wall());
                l.addLevelObject(9, 25, new Wall());
                l.addLevelObject(9, 26, new Wall());
                l.addLevelObject(9, 27, new Wall());
                l.addLevelObject(9, 28, new Wall());
                l.addLevelObject(9, 29, new Wall());
                l.addLevelObject(9, 30, new Wall());
                l.addLevelObject(10, 16, new Wall());
                l.addLevelObject(10, 30, new Wall());
                l.addLevelObject(11, 16, new Wall());
                l.addLevelObject(11, 30, new Wall());
                l.addLevelObject(12, 16, new Wall());
                l.addLevelObject(12, 30, new Wall());
                l.addLevelObject(13, 16, new Wall());
                l.addLevelObject(13, 30, new Wall());
                l.addLevelObject(14, 16, new Wall());
                l.addLevelObject(14, 30, new Wall());
                l.addLevelObject(15, 16, new Wall());
                l.addLevelObject(15, 30, new Wall());
                l.addLevelObject(16, 16, new Wall());
                l.addLevelObject(16, 30, new Wall());
                l.addLevelObject(17, 16, new Wall());
                l.addLevelObject(17, 17, new Wall());
                l.addLevelObject(17, 18, new Wall());
                l.addLevelObject(17, 19, new Wall());
                l.addLevelObject(17, 20, new Wall());
                l.addLevelObject(17, 21, new Wall());
                l.addLevelObject(17, 22, new Wall());
                l.addLevelObject(17, 23, new Wall());
                l.addLevelObject(17, 24, new Wall());
                l.addLevelObject(17, 25, new Wall());
                l.addLevelObject(17, 26, new Wall());
                l.addLevelObject(17, 27, new Wall());
                l.addLevelObject(17, 28, new Wall());
                l.addLevelObject(17, 29, new Wall());
                l.addLevelObject(17, 30, new Wall());

                //Room 2
                l.addLevelObject(2, 19, new Wall());
                l.addLevelObject(2, 20, new Wall());
                l.addLevelObject(2, 21, new Wall());
                l.addLevelObject(2, 22, new Wall());
                l.addLevelObject(2, 23, new Wall());
                l.addLevelObject(3, 23, new Wall());
                l.addLevelObject(4, 19, new Wall());
                l.addLevelObject(4, 23, new Wall());
                l.addLevelObject(5, 19, new Wall());
                l.addLevelObject(5, 23, new Wall());
                l.addLevelObject(6, 19, new Wall());
                l.addLevelObject(6, 21, new Wall());
                l.addLevelObject(6, 22, new Wall());
                l.addLevelObject(6, 23, new Wall());

                //Room 3
                l.addLevelObject(2, 7, new Wall());
                l.addLevelObject(2, 8, new Wall());
                l.addLevelObject(2, 9, new Wall());
                l.addLevelObject(2, 10, new Wall());
                l.addLevelObject(2, 11, new Wall());
                l.addLevelObject(2, 12, new Wall());
                l.addLevelObject(2, 13, new Wall());
                l.addLevelObject(2, 14, new Wall());
                l.addLevelObject(3, 7, new Wall());
                l.addLevelObject(3, 14, new Wall());
                l.addLevelObject(4, 7, new Wall());
                l.addLevelObject(5, 7, new Wall());
                l.addLevelObject(5, 14, new Wall());
                l.addLevelObject(6, 14, new Wall());
                l.addLevelObject(7, 7, new Wall());
                l.addLevelObject(7, 8, new Wall());
                l.addLevelObject(7, 9, new Wall());
                l.addLevelObject(7, 10, new Wall());
                l.addLevelObject(7, 11, new Wall());
                l.addLevelObject(7, 12, new Wall());
                l.addLevelObject(7, 13, new Wall());
                l.addLevelObject(7, 14, new Wall());

                //Room 4
                l.addLevelObject(8, 2, new Wall());
                l.addLevelObject(8, 4, new Wall());
                l.addLevelObject(8, 5, new Wall());
                l.addLevelObject(8, 6, new Wall());
                l.addLevelObject(8, 7, new Wall());
                l.addLevelObject(8, 8, new Wall());
                l.addLevelObject(8, 9, new Wall());
                l.addLevelObject(9, 2, new Wall());
                l.addLevelObject(9, 9, new Wall());
                l.addLevelObject(10, 2, new Wall());
                l.addLevelObject(10, 9, new Wall());
                l.addLevelObject(11, 2, new Wall());
                l.addLevelObject(11, 9, new Wall());
                l.addLevelObject(12, 2, new Wall());
                l.addLevelObject(12, 9, new Wall());
                l.addLevelObject(13, 2, new Wall());
                l.addLevelObject(13, 9, new Wall());
                l.addLevelObject(14, 2, new Wall());
                l.addLevelObject(14, 9, new Wall());
                l.addLevelObject(15, 2, new Wall());
                l.addLevelObject(15, 9, new Wall());
                l.addLevelObject(16, 2, new Wall());
                l.addLevelObject(16, 9, new Wall());
                l.addLevelObject(17, 2, new Wall());
                l.addLevelObject(17, 3, new Wall());
                l.addLevelObject(17, 4, new Wall());
                l.addLevelObject(17, 5, new Wall());
                l.addLevelObject(17, 7, new Wall());
                l.addLevelObject(17, 8, new Wall());
                l.addLevelObject(17, 9, new Wall());

                //Room 5
                l.addLevelObject(19, 1, new Wall());
                l.addLevelObject(19, 2, new Wall());
                l.addLevelObject(19, 3, new Wall());
                l.addLevelObject(19, 4, new Wall());
                l.addLevelObject(19, 5, new Wall());
                l.addLevelObject(19, 6, new Wall());
                l.addLevelObject(19, 8, new Wall());
                l.addLevelObject(19, 9, new Wall());
                l.addLevelObject(19, 10, new Wall());
                l.addLevelObject(19, 11, new Wall());
                l.addLevelObject(19, 12, new Wall());
                l.addLevelObject(20, 1, new Wall());
                l.addLevelObject(20, 12, new Wall());
                l.addLevelObject(21, 1, new Wall());
                l.addLevelObject(21, 12, new Wall());
                l.addLevelObject(22, 1, new Wall());
                l.addLevelObject(22, 12, new Wall());
                l.addLevelObject(23, 1, new Wall());
                l.addLevelObject(23, 12, new Wall());
                l.addLevelObject(24, 1, new Wall());
                l.addLevelObject(24, 12, new Wall());
                l.addLevelObject(25, 1, new Wall());
                l.addLevelObject(25, 2, new Wall());
                l.addLevelObject(25, 3, new Wall());
                l.addLevelObject(25, 4, new Wall());
                l.addLevelObject(25, 5, new Wall());
                l.addLevelObject(25, 6, new Wall());
                l.addLevelObject(25, 7, new Wall());
                l.addLevelObject(25, 8, new Wall());
                l.addLevelObject(25, 9, new Wall());
                l.addLevelObject(25, 10, new Wall());
                l.addLevelObject(25, 12, new Wall());

                //Room 6
                l.addLevelObject(20, 15, new Wall());
                l.addLevelObject(20, 16, new Wall());
                l.addLevelObject(20, 17, new Wall());
                l.addLevelObject(20, 18, new Wall());
                l.addLevelObject(20, 19, new Wall());
                l.addLevelObject(20, 20, new Wall());
                l.addLevelObject(20, 21, new Wall());
                l.addLevelObject(20, 22, new Wall());
                l.addLevelObject(20, 23, new Wall());
                l.addLevelObject(20, 24, new Wall());
                l.addLevelObject(20, 25, new Wall());
                l.addLevelObject(20, 26, new Wall());
                l.addLevelObject(20, 27, new Wall());
                l.addLevelObject(20, 28, new Wall());
                l.addLevelObject(20, 29, new Wall());
                l.addLevelObject(20, 30, new Wall());
                l.addLevelObject(20, 31, new Wall());
                l.addLevelObject(21, 15, new Wall());
                l.addLevelObject(21, 31, new Wall());
                l.addLevelObject(22, 15, new Wall());
                l.addLevelObject(22, 31, new Wall());
                l.addLevelObject(23, 15, new Wall());
                l.addLevelObject(23, 31, new Wall());
                l.addLevelObject(25, 15, new Wall());
                l.addLevelObject(25, 31, new Wall());
                l.addLevelObject(26, 15, new Wall());
                l.addLevelObject(26, 31, new Wall());
                l.addLevelObject(27, 15, new Wall());
                l.addLevelObject(27, 31, new Wall());
                l.addLevelObject(28, 15, new Wall());
                l.addLevelObject(28, 16, new Wall());
                l.addLevelObject(28, 17, new Wall());
                l.addLevelObject(28, 18, new Wall());
                l.addLevelObject(28, 19, new Wall());
                l.addLevelObject(28, 20, new Wall());
                l.addLevelObject(28, 21, new Wall());
                l.addLevelObject(28, 22, new Wall());
                l.addLevelObject(28, 23, new Wall());
                l.addLevelObject(28, 24, new Wall());
                l.addLevelObject(28, 25, new Wall());
                l.addLevelObject(28, 26, new Wall());
                l.addLevelObject(28, 27, new Wall());
                l.addLevelObject(28, 28, new Wall());
                l.addLevelObject(28, 29, new Wall());
                l.addLevelObject(28, 30, new Wall());
                l.addLevelObject(28, 31, new Wall());

                //Floor R1
                l.addLevelObject(9, 20, new Floor());
                for (int i = 17; i < 30; i++) {
                    for (int j = 10; j < 17; j++) {
                        l.addLevelObject(j, i, new Floor());
                    }
                }

                //Floor R1-2
                l.addLevelObject(7, 20, new Floor());
                l.addLevelObject(8, 20, new Floor());

                //Floor R2
                l.addLevelObject(3, 19, new Floor());
                l.addLevelObject(3, 20, new Floor());
                l.addLevelObject(3, 21, new Floor());
                l.addLevelObject(3, 22, new Floor());
                l.addLevelObject(4, 20, new Floor());
                l.addLevelObject(4, 21, new Floor());
                l.addLevelObject(4, 22, new Floor());
                l.addLevelObject(5, 20, new Floor());
                l.addLevelObject(5, 21, new Floor());
                l.addLevelObject(5, 22, new Floor());
                l.addLevelObject(6, 20, new Floor());

                //Floor R2-3
                l.addLevelObject(3, 17, new Floor());
                l.addLevelObject(3, 18, new Floor());
                l.addLevelObject(4, 15, new Floor());
                l.addLevelObject(4, 16, new Floor());
                l.addLevelObject(4, 17, new Floor());

                //Floor R3
                l.addLevelObject(3, 8, new Floor());
                l.addLevelObject(3, 9, new Floor());
                l.addLevelObject(3, 10, new Floor());
                l.addLevelObject(3, 11, new Floor());
                l.addLevelObject(3, 12, new Floor());
                l.addLevelObject(3, 13, new Floor());
                l.addLevelObject(4, 8, new Floor());
                l.addLevelObject(4, 9, new Floor());
                l.addLevelObject(4, 10, new Floor());
                l.addLevelObject(4, 11, new Floor());
                l.addLevelObject(4, 12, new Floor());
                l.addLevelObject(4, 13, new Floor());
                l.addLevelObject(4, 14, new Floor());
                l.addLevelObject(5, 8, new Floor());
                l.addLevelObject(5, 9, new Floor());
                l.addLevelObject(5, 10, new Floor());
                l.addLevelObject(5, 11, new Floor());
                l.addLevelObject(5, 12, new Floor());
                l.addLevelObject(5, 13, new Floor());
                l.addLevelObject(6, 7, new Floor());
                l.addLevelObject(6, 8, new Floor());
                l.addLevelObject(6, 9, new Floor());
                l.addLevelObject(6, 10, new Floor());
                l.addLevelObject(6, 11, new Floor());
                l.addLevelObject(6, 12, new Floor());
                l.addLevelObject(6, 13, new Floor());

                //Floor R3-4
                l.addLevelObject(4, 2, new Floor());
                l.addLevelObject(4, 3, new Floor());
                l.addLevelObject(4, 4, new Floor());
                l.addLevelObject(4, 5, new Floor());
                l.addLevelObject(5, 2, new Floor());
                l.addLevelObject(5, 5, new Floor());
                l.addLevelObject(6, 2, new Floor());
                l.addLevelObject(6, 3, new Floor());
                l.addLevelObject(6, 5, new Floor());
                l.addLevelObject(6, 6, new Floor());
                l.addLevelObject(7, 3, new Floor());

                //Floor R4
                l.addLevelObject(8, 3, new Floor());
                for (int i = 3; i < 9; i++) {
                    for (int j = 9; j < 17; j++) {
                        l.addLevelObject(j, i, new Floor());
                    }
                }
                l.addLevelObject(17, 6, new Floor());

                //Floor R4-5
                l.addLevelObject(18, 6, new Floor());
                l.addLevelObject(18, 7, new Floor());

                //Floor R5
                l.addLevelObject(19, 7, new Floor());
                for (int i = 2; i < 12; i++) {
                    for (int j = 20; j < 25; j++) {
                        l.addLevelObject(j, i, new Floor());
                    }
                }
                l.addLevelObject(25, 11, new Floor());

                //Floor R5-6
                l.addLevelObject(24, 13, new Floor());
                l.addLevelObject(24, 14, new Floor());
                l.addLevelObject(25, 13, new Floor());
                l.addLevelObject(26, 9, new Floor());
                l.addLevelObject(26, 10, new Floor());
                l.addLevelObject(26, 11, new Floor());
                l.addLevelObject(26, 13, new Floor());
                l.addLevelObject(27, 9, new Floor());
                l.addLevelObject(27, 13, new Floor());
                l.addLevelObject(28, 9, new Floor());
                l.addLevelObject(28, 10, new Floor());
                l.addLevelObject(28, 11, new Floor());
                l.addLevelObject(28, 12, new Floor());
                l.addLevelObject(28, 13, new Floor());

                //Floor R6
                for (int i = 16; i < 31; i++) {
                    for (int j = 21; j < 28; j++) {
                        l.addLevelObject(j, i, new Floor());
                    }
                }
                l.addLevelObject(24, 15, new Floor());

                //Monster & Items
                //Room 1
                l.addLevelObject(15, 23, hero1);
                l.addLevelObject(10, 29, new Potions(70, "♥", "Potion"));
                l.addLevelObject(11, 29, new Weapon(75, "W", "Bow"));
                l.addLevelObject(12, 29, new Armor("Shield", "A", 40));
                l.addLevelObject(13, 29, new Gold(50, "$", "Gold pieces"));
                
                
                
                //Room 2
                l.addLevelObject(3, 20, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));
                l.addLevelObject(3, 21, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));
                l.addLevelObject(3, 22, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));

                //Room 3
                l.addLevelObject(3, 9, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));
                l.addLevelObject(3, 13, new Potions(100, "♥", "Potion"));
                l.addLevelObject(5, 9, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));
                l.addLevelObject(6, 13, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));

                //Room 4
                l.addLevelObject(9, 8, new Ring(25, 25, 25, "Ô", "Ruby ring"));
                l.addLevelObject(11, 8, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));
                l.addLevelObject(12, 8, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));
                l.addLevelObject(14, 5, new Dragon (80, 20, 35, 35, 110, "Fire Dragon", difficulty));
                l.addLevelObject(15, 8, new Gold(75, "$", "Gold pieces"));
                l.addLevelObject(16, 8, new Gold(75, "$", "Gold pieces"));

                //Room 5
                l.addLevelObject(20, 7, new Potions(100, "♥", "Potion"));
                l.addLevelObject(22, 2, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));
                l.addLevelObject(22, 3, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));
                l.addLevelObject(23, 2, new Potions(100, "♥", "Potion"));
                l.addLevelObject(23, 3, new Skeleton(40, 20, 10, 10, 50, "Large Skeleton", difficulty));
                l.addLevelObject(24, 2, new Armor("Steel Helmet", "A", 60));
                l.addLevelObject(24, 3, new Ghost(35, 30, 5, 25, 75, "Great Ghost", difficulty));
                l.addLevelObject(24, 10, new Dragon(80, 20, 35, 35, 110, "Fire Dragon", difficulty));
                l.addLevelObject(24, 11, new Dragon(80, 20, 35, 35, 110, "Fire Dragon", difficulty));

                //Room 6
                l.addLevelObject(20, 16, new Potions(350, "♥", "Great Potion"));
                l.addLevelObject(24, 29, new Boss(100, 20, 25, 300, 500, "Boss", difficulty));
                l.setCurrUsage(2);
                break;
        }
    }

    /**
     * player lost method.
     *
     * @param h Hero
     */
    public final void lose(Hero h) {
        score1.addScore(h.getName(), h.getGold());
        try {
            rw1.writeObject(score1);
        } catch (IOException ex) {
        }

        go1.lost(score1);
        this.dispose();
    }

    /**
     * Keylistener class that checks key presses to key event codes to match
     * input to player actions.
     */
    public class KeyboardListener extends KeyAdapter {

        public void setDisable(boolean disable) {
            this.disable = disable;
        }
        private boolean disable = false;

        @Override//keypress listener method for player movement.
        public final void keyPressed(final KeyEvent e) {
            int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_LEFT && !hasMoved && !disable) {
                hasMoved = true;
                Hero tempHero = (Hero) level1.getGrid(level1.heroY(),
                        level1.heroX());

                if (level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1) instanceof Creature && level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1).getClass() != Creature.class) {
                    combat.attack((Creature) level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1), tempHero, level1);
                } else if (level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1) instanceof Items && level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1).getClass() != Items.class) {
                    pickup.PickUpItem((Items) level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() - 1), tempHero, level1);
                }

                if (level1.getGrid(tempHero.getArrayX(),
                        tempHero.getArrayY() - 1).isIsWalkable()) {
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY(), new Floor());
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY() - 1, tempHero);
                }
                ai.aiMonsters(level1);


            } else if (keyCode == KeyEvent.VK_RIGHT && !hasMoved && !disable) {
                hasMoved = true;
                Hero tempHero = (Hero) level1.getGrid(level1.heroY(),
                        level1.heroX());

                if (level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1) instanceof Creature && level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1).getClass() != Creature.class) {
                    combat.attack((Creature) level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1), tempHero, level1);
                } else if (level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1) instanceof Items && level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1).getClass() != Items.class) {
                    pickup.PickUpItem((Items) level1.getGrid(tempHero.getArrayX(), tempHero.getArrayY() + 1), tempHero, level1);
                }

                if (level1.getGrid(tempHero.getArrayX(),
                        tempHero.getArrayY() + 1).isIsWalkable()) {
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY(), new Floor());
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY() + 1, tempHero);
                }
                ai.aiMonsters(level1);
            } else if (keyCode == KeyEvent.VK_UP && !hasMoved && !disable) {
                hasMoved = true;
                Hero tempHero = (Hero) level1.getGrid(level1.heroY(),
                        level1.heroX());

                if (level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()) instanceof Creature && level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()).getClass() != Creature.class) {
                    combat.attack((Creature) level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()), tempHero, level1);
                } else if (level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()) instanceof Items && level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()).getClass() != Items.class) {
                    pickup.PickUpItem((Items) level1.getGrid(tempHero.getArrayX() - 1, tempHero.getArrayY()), tempHero, level1);
                }

                if (level1.getGrid(tempHero.getArrayX() - 1,
                        tempHero.getArrayY()).isIsWalkable()) {
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY(), new Floor());
                    level1.addLevelObject(tempHero.getArrayX() - 1,
                            tempHero.getArrayY(), tempHero);
                }
                ai.aiMonsters(level1);
            } else if (keyCode == KeyEvent.VK_DOWN && !hasMoved && !disable) {
                hasMoved = true;
                Hero tempHero = (Hero) level1.getGrid(level1.heroY(),
                        level1.heroX());

                if (level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()) instanceof Creature && level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()).getClass() != Creature.class) {
                    combat.attack((Creature) level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()), tempHero, level1);
                } else if (level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()) instanceof Items && level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()).getClass() != Items.class) {
                    pickup.PickUpItem((Items) level1.getGrid(tempHero.getArrayX() + 1, tempHero.getArrayY()), tempHero, level1);
                }

                if (level1.getGrid(tempHero.getArrayX() + 1,
                        tempHero.getArrayY()).isIsWalkable()) {
                    level1.addLevelObject(tempHero.getArrayX(),
                            tempHero.getArrayY(), new Floor());
                    level1.addLevelObject(tempHero.getArrayX() + 1,
                            tempHero.getArrayY(), tempHero);
                }
                ai.aiMonsters(level1);



            }
            if(level1.getCurrUsage()==1) {
            if (level1.heroX() == 20 && level1.heroY() == 9) {
                Sound player = new Sound();
                gui1.addEventItem(null, hero1, " ", " ", " ", 6);
                player.playwav("boss.wav");
                player.playmid("imperial.mid");
            }
            }
            if(level1.getCurrUsage()==2) {
                if(level1.heroX()==16 && level1.heroY()==24 ) {
                    gui1.addEventItem(null, hero1, " ", " ", " ", 6);
                }
            }
        }

        @Override // Keyrelease Method to check if key is held.
        public final void keyReleased(final KeyEvent e) {
            int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_LEFT && hasMoved) {
                hasMoved = false;
            }
            if (keyCode == KeyEvent.VK_RIGHT && hasMoved) {
                hasMoved = false;
            }
            if (keyCode == KeyEvent.VK_UP && hasMoved) {
                hasMoved = false;
            }
            if (keyCode == KeyEvent.VK_DOWN && hasMoved) {
                hasMoved = false;
            }
        }
    }
}
